package com.situ.day26;

// 懒汉式
public class Singleton1 {
    private volatile static Singleton1 instance;

    private Singleton1() {

    }

    // 双重检查加锁
    public static Singleton1 getInstance() {
        if (instance == null) {
            synchronized (Singleton1.class) {
                if (instance == null) {
                    instance = new Singleton1();
                }
            }
        }

        return instance;
    }
}
